﻿<phone:PhoneApplicationPage
    x:Class="SC2TV.StreamPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewModel="clr-namespace:SC2TV.ViewModel"
    xmlns:wpExtensions="clr-namespace:WPExtensions;assembly=WPExtensions"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.Resources>
        <viewModel:StreamViewModel x:Key="VM" />
    </phone:PhoneApplicationPage.Resources>
    <phone:PhoneApplicationPage.DataContext>
        <Binding Source="{StaticResource VM}"/>
    </phone:PhoneApplicationPage.DataContext>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <wpExtensions:AdvancedApplicationBar>
            <wpExtensions:AdvancedApplicationBarIconButton Text="{Binding Text.Emotions}" IconUri="/Assets/Icons/ewbte2.png" Click="OpenEmotionsList"/>
            <wpExtensions:AdvancedApplicationBarIconButton Text="{Binding Text.Send}" IconUri="/Assets/Icons/appbar.message.send.png" Command="{Binding SendMessage}"/>
        </wpExtensions:AdvancedApplicationBar>

        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding Text.ApplicationTitle}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{Binding ChannelName}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <UserControl Grid.Row="1" Name="EmotionsGrid" Visibility="Collapsed">
            <phone:LongListSelector LayoutMode="Grid" GridCellSize="90,90" ItemsSource="{Binding Emotions}" SelectionChanged="EmotionSelected">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding Image}"/>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>
        </UserControl>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <ScrollViewer Grid.Row="0" Name="scrollViewer" >
                <ItemsControl Name="chatControl" ItemsSource="{Binding ChatList}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0,5,0,5">
                                <RichTextBox Loaded="RichTextBoxLoaded"/>
                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu>
                                        <toolkit:MenuItem Click="Reply" Header="{Binding Text.Reply}" />
                                        <toolkit:MenuItem Click="OpenPrivateChat" Header="{Binding Text.SendPM}"/>
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
            <TextBox Text="{Binding Message,Mode=TwoWay}" Grid.Row="1"/>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>